package cn.jinjie.day05.test8;

import java.util.Arrays;

public class Demo3 {
    public static void main(String[] args) {
        int[] arr1 = new int[5];
        System.out.println(Arrays.toString(arr1));
        String s = "91 52 36 14 22";
        String[] arr2 = s.split(" ");
        for (int i = 0; i < arr1.length; i++) {
            arr1[i] = Integer.parseInt(arr2[i]);
            System.out.print(arr1[i] + " ");
        }
        System.out.println();
        System.out.println(arr1[3]);

        //排序 默认升序
        Arrays.sort(arr1);
        System.out.println(Arrays.toString(arr1));

        //二分查找 返回索引
        //如果数据找不到   会找到数据应该在的索引位置index   返回的是 -index-1
        int index = Arrays.binarySearch(arr1, 22);
        System.out.println(index);

    }
}
